use winnowedmturk.dta
append using winnowedlucid1.dta
append using winnowedlucid2.dta

drop if outcome_pooled==.

/* note that there are leaners only in the lucid studies */
gen leaner=strpos(pid7,"Indep")~=0 | strpos(pid7,"Lean")
gen strong=strpos(pid7,"Strong")~=0

tab sample, gen(sd_)
drop sd_1
label var sd_2 "Sample = Lucid #2"
label var sd_3 "Sample = MTurk"

* Perform randomization test, save chi-2 values

gen chi2randtest=.
label var chi2randtest "Chi2 Randomization Test"

gen chi2pvalue=.
label var chi2pvalue "Chi2 p-value"

gen pweight=1/weight
gen peitherweight=1/eitherweight

table sample treat3cat , c(mean pweight n pweight)
table sample  , c(mean pweight n pweight)

mlogit treat3cat person_is_dem_not_rep d_* if sample=="turk1" [pweight=pweight]
replace chi2randtest=`e(chi2)' if sample=="turk1"
replace chi2pvalue=`e(p)' if sample=="turk1"
mlogit treat3cat person_is_dem_not_rep d_* if sample=="lucid1" [pweight=pweight]
replace chi2randtest=`e(chi2)' if sample=="lucid1"
replace chi2pvalue=`e(p)' if sample=="lucid1"
mlogit treat3cat person_is_dem_not_rep d_* if sample=="lucid2" [pweight=pweight]
replace chi2randtest=`e(chi2)' if sample=="lucid2"
replace chi2pvalue=`e(p)' if sample=="lucid2"

table sample treat3cat, c(mean pweight sd pweight)

* Summary stats, randomization tests Appendix Table 1

outsum person_is_dem_not_rep d_* chi2randtest chi2pvalue using AppendixTable01_SummStatsRandomizationTests.out if sample=="turk1", bracket ctitle("Sample 1: Mturk") replace
outsum person_is_dem_not_rep d_* chi2randtest chi2pvalue using AppendixTable01_SummStatsRandomizationTests.out if sample=="lucid1", bracket ctitle("Sample 2: Lucid 1") append
outsum person_is_dem_not_rep d_* chi2randtest chi2pvalue using AppendixTable01_SummStatsRandomizationTests.out if sample=="lucid2", bracket ctitle("Sample 3: Lucid 2") append

* Appendix Table A3: Effect of PID on values
label var values_pooled "Good Values, Pooled (-3 to 3)"
regress values_pooled person_is_dem_not_rep pid_profile_match pid_profile_mismatch sd_*, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') addnote("Pooled analysis") replace

regress values_pooled pid_profile_match pid_profile_mismatch sd_* if person_is_dem_not_rep==1, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Democrats") append

regress values_pooled pid_profile_match pid_profile_mismatch sd_* if person_is_dem_not_rep==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Republicans") append

regress values_pooled pid_profile_match pid_profile_mismatch if sample=="turk1" & person_is_dem_not_rep==1 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Dems. Sample 1: Mturk") append

regress values_pooled pid_profile_match pid_profile_mismatch if sample=="turk1" & person_is_dem_not_rep==0 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Reps. Sample 1: Mturk") append

regress values_pooled pid_profile_match pid_profile_mismatch if sample=="lucid1" & person_is_dem_not_rep==1 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Dems. Sample 2: Lucid 1") append

regress values_pooled pid_profile_match pid_profile_mismatch if sample=="lucid1" & person_is_dem_not_rep==0 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Reps. Sample 2: Lucid 1") append

regress values_pooled pid_profile_match pid_profile_mismatch if sample=="lucid2" & person_is_dem_not_rep==1 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Dems. Sample 3: Lucid 2") append

regress values_pooled pid_profile_match pid_profile_mismatch if sample=="lucid2" & person_is_dem_not_rep==0 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable04_EffectOfMatchOnValues.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Reps. Sample 3: Lucid 2") append

* Control group gaps. Table 2 and Appendix Table 2

preserve
keep if treat_control==1

regress outcome_pooled person_is_dem_not_rep pid_profile_match pid_profile_mismatch sd_*, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') addnote("Pooled analysis") replace
outreg2 person_is_dem_not_rep pid_profile_match pid_profile_mismatch sd_* using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') excel replace

regress outcome_pooled pid_profile_match pid_profile_mismatch sd_* if person_is_dem_not_rep==1, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Democrats") append
outreg2 pid_profile_match pid_profile_mismatch sd_* using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Democrats") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch sd_* if person_is_dem_not_rep==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Republicans") append
outreg2 pid_profile_match pid_profile_mismatch sd_* using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Republicans") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch if sample=="turk1" & person_is_dem_not_rep==1 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Dems. Sample 1: Mturk") append
outreg2 pid_profile_match pid_profile_mismatch using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Dems. Sample 1: Mturk") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch if sample=="turk1" & person_is_dem_not_rep==0 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Reps. Sample 1: Mturk") append
outreg2 pid_profile_match pid_profile_mismatch using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Reps. Sample 1: Mturk") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch if sample=="lucid1" & person_is_dem_not_rep==1 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Dems. Sample 2: Lucid 1") append
outreg2 pid_profile_match pid_profile_mismatch using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Dems. Sample 2: Lucid 1") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch if sample=="lucid1" & person_is_dem_not_rep==0 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Reps. Sample 2: Lucid 1") append
outreg2 pid_profile_match pid_profile_mismatch using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Reps. Sample 2: Lucid 1") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch if sample=="lucid2" & person_is_dem_not_rep==1 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Dems. Sample 3: Lucid 2") append
outreg2 pid_profile_match pid_profile_mismatch using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Dems. Sample 3: Lucid 2") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch if sample=="lucid2" & person_is_dem_not_rep==0 , robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table02_ControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Reps. Sample 3: Lucid 2") append
outreg2 pid_profile_match pid_profile_mismatch using Table02_ControlGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1')  cttop("Reps. Sample 3: Lucid 2") excel append

* This is now going in appendix Table 2.

regress outcome_pooled person_is_dem_not_rep pid_profile_match pid_profile_mismatch sd_* if profile_is_eitherjustclntrmp==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable02_RobustnessControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Excluding Clinton/Trump Profiles") replace

regress outcome_pooled person_is_dem_not_rep pid_profile_match pid_profile_mismatch sd_* if profile_is_eitherjustdemrep==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable02_RobustnessControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Excluding Dem/Rep Profiles") append

regress outcome_pooled pid_profile_match pid_profile_mismatch sd_* if person_is_dem_not_rep==1 & leaner==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable02_RobustnessControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Democrats No Leaners") append

regress outcome_pooled pid_profile_match pid_profile_mismatch sd_* if person_is_dem_not_rep==0 & leaner==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable02_RobustnessControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Republicans No Leaners") append

regress outcome_pooled pid_profile_match pid_profile_mismatch sd_2 if person_is_dem_not_rep==1 & strong==1, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable02_RobustnessControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Strong Democrats") append

regress outcome_pooled pid_profile_match pid_profile_mismatch sd_2 if person_is_dem_not_rep==0 & strong==1, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable02_RobustnessControlGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1') ctitle("Strong Republicans") append

restore

* Treatment effects. Table 03.

regress outcome_pooled person_is_dem_not_rep pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either sd_* [pweight=peitherweight], robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') addnote("Pooled analysis") replace
outreg2 person_is_dem_not_rep pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either sd_*  using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') excel replace

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either sd_* if person_is_dem_not_rep==1 [pweight=peitherweight], robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Democrats") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either sd_* using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Democrats") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either sd_* if person_is_dem_not_rep==0 [pweight=peitherweight], robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Republicans") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either sd_* using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Republicans") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either if sample=="turk1" & person_is_dem_not_rep==1, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Dems. Sample 1: Mturk") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Dems. Sample 1: Mturk") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either if sample=="turk1" & person_is_dem_not_rep==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Reps. Sample 1: Mturk") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Reps. Sample 1: Mturk") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either if sample=="lucid1" & person_is_dem_not_rep==1, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Dems. Sample 2: Lucid 1") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Dems. Sample 2: Lucid 1") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either if sample=="lucid1" & person_is_dem_not_rep==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Reps. Sample 2: Lucid 1") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Reps. Sample 2: Lucid 1") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either if sample=="lucid2" & person_is_dem_not_rep==1, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Dems. Sample 3: Lucid 2") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Dems. Sample 3: Lucid 2") excel append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either if sample=="lucid2" & person_is_dem_not_rep==0, robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_either)-(pid_profile_mismatch_either)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
*outreg using Table03_TreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') ctitle("Reps. Sample 3: Lucid 2") append
outreg2 pid_profile_match pid_profile_mismatch pid_profile_match_either pid_profile_mismatch_either treat_either using Table03_TreatmentEffectsPartisanGaps, sideway stats(coef se) 10pct dec(3) label addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Either", `est2' ,"p-value Either",`pvalue2') cttop("Reps. Sample 3: Lucid 2") excel append

* Partitioning treatment effects estimates. Appendix Table 03
regress outcome_pooled person_is_dem_not_rep pid_profile_match pid_profile_mismatch pid_profile_match_steam pid_profile_mismatch_steam pid_profile_match_warn pid_profile_mismatch_warn treat_steam treat_warn sd_* [pweight=pweight], robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_steam)-(pid_profile_mismatch_steam)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_warn)-(pid_profile_mismatch_warn)
local est3 = r(estimate)
local pvalue3 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable03_PartitionedTreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Steam", `est2' ,"p-value Steam",`pvalue2', "Reduction Warn", `est3' ,"p-value Warn",`pvalue3') addnote("Pooled analysis") replace

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_steam pid_profile_mismatch_steam pid_profile_match_warn pid_profile_mismatch_warn treat_steam treat_warn sd_* if person_is_dem_not_rep==1 [pweight=pweight], robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_steam)-(pid_profile_mismatch_steam)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_warn)-(pid_profile_mismatch_warn)
local est3 = r(estimate)
local pvalue3 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable03_PartitionedTreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Steam", `est2' ,"p-value Steam",`pvalue2', "Reduction Warn", `est3' ,"p-value Warn",`pvalue3') ctitle("Democrats") append

regress outcome_pooled pid_profile_match pid_profile_mismatch pid_profile_match_steam pid_profile_mismatch_steam pid_profile_match_warn pid_profile_mismatch_warn treat_steam treat_warn sd_* if person_is_dem_not_rep==0 [pweight=pweight], robust
lincom pid_profile_match - pid_profile_mismatch
local est1 = r(estimate)
local pvalue1 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_steam)-(pid_profile_mismatch_steam)
local est2 = r(estimate)
local pvalue2 = ttail(r(df),abs(r(estimate)/r(se)))*2
lincom (pid_profile_match_warn)-(pid_profile_mismatch_warn)
local est3 = r(estimate)
local pvalue3 = ttail(r(df),abs(r(estimate)/r(se)))*2
outreg using AppendixTable03_PartitionedTreatmentEffectsPartisanGaps.out, se bracket rdec(3) adec(3) 3aster addstat("Diff Match - Unmatch", `est1' ,"p-value",`pvalue1', "Reduction Steam", `est2' ,"p-value Steam",`pvalue2', "Reduction Warn", `est3' ,"p-value Warn",`pvalue3') ctitle("Republicans") append

*lincom (pid_profile_match+pid_profile_match_steam)-(pid_profile_mismatch+pid_profile_mismatch_steam)
*lincom (pid_profile_match+pid_profile_match_warn)-(pid_profile_mismatch+pid_profile_mismatch_warn)
